package com.resign.carl.observer;

import com.resign.carl.observer.api.impl.CurrentConditionsDisplay;
import com.resign.carl.observer.api.impl.StatisticsDisplay;
import com.resign.carl.observer.api.impl.WeatherData;

/**
 * 观察者模式
 * Created by carl.zhao on 2016/6/13.
 */
public class WeatherStation {
    public static void main(String[] args) {
        WeatherData weatherData = new WeatherData();
        CurrentConditionsDisplay conditionsDisplay = new CurrentConditionsDisplay(weatherData);
        StatisticsDisplay statisticsDisplay = new StatisticsDisplay(weatherData);
        weatherData.registerObserver(conditionsDisplay);
        weatherData.registerObserver(statisticsDisplay);
        weatherData.setMeasurements(80, 65, 30.4F);
        weatherData.setMeasurements(82, 70, 29.2f);
        weatherData.setMeasurements(83, 70, 29.2f);
    }
}
